package com.winway.sixbook.ui;

import java.util.ArrayList;
import java.util.HashMap;

import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;

import com.winway.sixbook.R;
import com.tritrees.easygridview.widget.AllEasyGridView;
import com.tritrees.easygridview.widget.EasyGridView;
import com.tritrees.easygridview.widget.EasyGridView.IHandleGridView;
import com.tritrees.easygridview.widget.ImageAdapter;

public class AllImageActivity extends Activity implements IHandleGridView
{
	private static final String strTag = "AllImageActivity";
	
	EasyGridView allEasyGridView;
	private ArrayList<HashMap<String, Object>> data;
	
	

	@Override
	protected void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_all_image);
		initData();
		initView();
	}
	
	private void initData()
	{
		data = new ArrayList<HashMap<String,Object>>();
		HashMap<String,Object> map;
		Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.ic_usericon_1);
		for(int i=0; i < 2; i++){
			map = new HashMap<String, Object>();
			map.put(EasyGridView.IMAGE, bmp);
			map.put(EasyGridView.TEXT, "娜美");
			data.add(map);
		}
	}

	private void initView()
	{
		allEasyGridView = (AllEasyGridView)findViewById(R.id.my_grid);
		ImageAdapter adapter = new ImageAdapter(this,true);
		allEasyGridView.initData(false, data, adapter);
		allEasyGridView.setHandleGridView(this);
	}

	@Override
	public void addImage()
	{
		Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.ic_usericon_1);
		HashMap<String,Object> map = new HashMap<String, Object>();
		map.put(EasyGridView.IMAGE, bmp);
		map.put(EasyGridView.TEXT, "娜美");
		allEasyGridView.getData().add(map);	
	}

	@Override
	public void delImage(int position)
	{
		allEasyGridView.getData().remove(position);
	}

	@Override
	public void queryImage(int position)
	{
		// TODO Auto-generated method stub
		
	}

}
